set more off

sort zipcode
merge zipcode using "zcta_cbsa_rel_10.dta"
drop if _m<3

gen region=1 if cbsa==14460
replace region=2 if cbsa==12700 | cbsa==39300
replace region=3 if cbsa==49340
replace region=4 if cbsa==38340 | cbsa==44140
label define region 1 "Boston Area" 2 "New Bedford/Cape Cod" 3 "Central MA" 4 "Western MA"
label values region region

gen leaner=q7a
recode leaner 2=1 1=2 3=.
gen senwleaners=q7
replace senwleaners=1 if leaner==1
replace senwleaners=2 if leaner==2
label define sen 1 "Gomez (Rep)" 2 "Markey (Dem)" 3 "someone else" 4 "not sure" 5 "would not vote"
label val senwleaners sen

gen incomecat=1 if faminc<=4
replace incomecat=2 if faminc>4 & faminc<10
replace incomecat=3 if faminc<97 & faminc>10

label define incomecat 1 "Less than $40k" 2 "$40k - $100k" 3 "Over $100k"
label values incomecat incomecat

gen ideo3=ideo5
recode ideo3 1/2=1 3=2 4/5=3 6=4
label define ideo3 1 "liberal" 2 "moderate" 3 "conservative"
label val ideo3 ideo3
label var ideo3 "Ideology 3 point"

gen age=2013-birthyr
gen agecat=1 if age<30
replace agecat=2 if age>29 & age<55
replace agecat=3 if age>54

label define agecat 1 "18-29" 2 "30-54" 3 "55+"
label values agecat agecat

gen vote2010=q5
recode vote2010 1/3=1 4/5=0
label define vote 1 "voted" 0 "did not vote"
label val vote2010 vote

gen vote2012=q5a
recode vote2012 1/3=1 4/5=0
label val vote2012 vote


gen likelyvoter=1 if q6<3 & gender==2
replace likelyvoter=1 if q6==1 & gender==1
replace likelyvoter=0 if q6==2 & senwleaners>2
replace likelyvoter=0 if senwleaners==5
replace likelyvoter=0 if vote2010==0 & vote2012==0
recode likelyvoter .=0


svyset [pw=weight]

* State of Nation

svy: tab q1
svy: tab q2

* Approval Ratings

* Obama
svy: tab q3a

svy: tab q3a if gender==1, stubw(30)
svy: tab q3a if gender==2, stubw(30)

svy: tab q3a if incomecat==1, stubw(30)
svy: tab q3a if incomecat==2, stubw(30)
svy: tab q3a if incomecat==3, stubw(30)

svy: tab q3a if pid3==1, stubw(30)
svy: tab q3a if pid3==2, stubw(30)
svy: tab q3a if pid3==3, stubw(30)

svy: tab q3a if ideo3==1, stubw(30)
svy: tab q3a if ideo3==2, stubw(30)
svy: tab q3a if ideo3==3, stubw(30)

svy: tab q3a if race==1, stubw(30)
svy: tab q3a if race==2, stubw(30)
svy: tab q3a if race==3, stubw(30)
svy: tab q3a if race==4, stubw(30)
svy: tab q3a if race==5, stubw(30)
svy: tab q3a if race==6, stubw(30)

svy: tab q3a if agecat==1, stubw(30)
svy: tab q3a if agecat==2, stubw(30)
svy: tab q3a if agecat==3, stubw(30)

*Deval Patrick
svy: tab q3b

svy: tab q3b if gender==1, stubw(30)
svy: tab q3b if gender==2, stubw(30)

svy: tab q3b if incomecat==1, stubw(30)
svy: tab q3b if incomecat==2, stubw(30)
svy: tab q3b if incomecat==3, stubw(30)

svy: tab q3b if pid3==1, stubw(30)
svy: tab q3b if pid3==2, stubw(30)
svy: tab q3b if pid3==3, stubw(30)

svy: tab q3b if ideo3==1, stubw(30)
svy: tab q3b if ideo3==2, stubw(30)
svy: tab q3b if ideo3==3, stubw(30)

svy: tab q3b if race==1, stubw(30)
svy: tab q3b if race==2, stubw(30)
svy: tab q3b if race==3, stubw(30)
svy: tab q3b if race==4, stubw(30)
svy: tab q3b if race==5, stubw(30)
svy: tab q3b if race==6, stubw(30)

svy: tab q3b if agecat==1, stubw(30)
svy: tab q3b if agecat==2, stubw(30)
svy: tab q3b if agecat==3, stubw(30)

svy: tab q3b if region==1, stubw(30)
svy: tab q3b if region==2, stubw(30)
svy: tab q3b if region==3, stubw(30)
svy: tab q3b if region==4, stubw(30)


* Elizabeth Warren
svy: tab q3c

svy: tab q3c if gender==1, stubw(30)
svy: tab q3c if gender==2, stubw(30)

svy: tab q3c if incomecat==1, stubw(30)
svy: tab q3c if incomecat==2, stubw(30)
svy: tab q3c if incomecat==3, stubw(30)

svy: tab q3c if pid3==1, stubw(30)
svy: tab q3c if pid3==2, stubw(30)
svy: tab q3c if pid3==3, stubw(30)

svy: tab q3c if ideo3==1, stubw(30)
svy: tab q3c if ideo3==2, stubw(30)
svy: tab q3c if ideo3==3, stubw(30)

svy: tab q3c if race==1, stubw(30)
svy: tab q3c if race==2, stubw(30)
svy: tab q3c if race==3, stubw(30)
svy: tab q3c if race==4, stubw(30)
svy: tab q3c if race==5, stubw(30)
svy: tab q3c if race==6, stubw(30)

svy: tab q3c if agecat==1, stubw(30)
svy: tab q3c if agecat==2, stubw(30)
svy: tab q3c if agecat==3, stubw(30)

svy: tab q3c if region==1, stubw(30)
svy: tab q3c if region==2, stubw(30)
svy: tab q3c if region==3, stubw(30)
svy: tab q3c if region==4, stubw(30)

*US Congress
svy: tab q3e

svy: tab q3e if gender==1, stubw(30)
svy: tab q3e if gender==2, stubw(30)

svy: tab q3e if incomecat==1, stubw(30)
svy: tab q3e if incomecat==2, stubw(30)
svy: tab q3e if incomecat==3, stubw(30)

svy: tab q3e if pid3==1, stubw(30)
svy: tab q3e if pid3==2, stubw(30)
svy: tab q3e if pid3==3, stubw(30)

svy: tab q3e if ideo3==1, stubw(30)
svy: tab q3e if ideo3==2, stubw(30)
svy: tab q3e if ideo3==3, stubw(30)

svy: tab q3e if race==1, stubw(30)
svy: tab q3e if race==2, stubw(30)
svy: tab q3e if race==3, stubw(30)
svy: tab q3e if race==4, stubw(30)
svy: tab q3e if race==5, stubw(30)
svy: tab q3e if race==6, stubw(30)

svy: tab q3e if agecat==1, stubw(30)
svy: tab q3e if agecat==2, stubw(30)
svy: tab q3e if agecat==3, stubw(30)

*MA Legislature
svy: tab q3f

svy: tab q3f if gender==1, stubw(30)
svy: tab q3f if gender==2, stubw(30)

svy: tab q3f if incomecat==1, stubw(30)
svy: tab q3f if incomecat==2, stubw(30)
svy: tab q3f if incomecat==3, stubw(30)

svy: tab q3f if pid3==1, stubw(30)
svy: tab q3f if pid3==2, stubw(30)
svy: tab q3f if pid3==3, stubw(30)

svy: tab q3f if ideo3==1, stubw(30)
svy: tab q3f if ideo3==2, stubw(30)
svy: tab q3f if ideo3==3, stubw(30)

svy: tab q3f if race==1, stubw(30)
svy: tab q3f if race==2, stubw(30)
svy: tab q3f if race==3, stubw(30)
svy: tab q3f if race==4, stubw(30)
svy: tab q3f if race==5, stubw(30)
svy: tab q3f if race==6, stubw(30)

svy: tab q3f if agecat==1, stubw(30)
svy: tab q3f if agecat==2, stubw(30)
svy: tab q3f if agecat==3, stubw(30)

svy: tab q3f if region==1, stubw(30)
svy: tab q3f if region==2, stubw(30)
svy: tab q3f if region==3, stubw(30)
svy: tab q3f if region==4, stubw(30)

* Senate Election Vote Preference

svy: tab senwleaners if likelyvoter==1, stubw(30)

svy: tab senwleaners if gender==1 & likelyvoter==1, stubw(30)
svy: tab senwleaners if gender==2 & likelyvoter==1, stubw(30)

svy: tab senwleaners if incomecat==1 & likelyvoter==1, stubw(30)
svy: tab senwleaners if incomecat==2 & likelyvoter==1, stubw(30)
svy: tab senwleaners if incomecat==3 & likelyvoter==1, stubw(30)

svy: tab senwleaners if pid3==1 & likelyvoter==1, stubw(30)
svy: tab senwleaners if pid3==2 & likelyvoter==1, stubw(30)
svy: tab senwleaners if pid3==3 & likelyvoter==1, stubw(30)

svy: tab senwleaners if ideo3==1 & likelyvoter==1, stubw(30)
svy: tab senwleaners if ideo3==2 & likelyvoter==1, stubw(30)
svy: tab senwleaners if ideo3==3 & likelyvoter==1, stubw(30)

svy: tab senwleaners if race==1 & likelyvoter==1, stubw(30)
svy: tab senwleaners if race==2 & likelyvoter==1, stubw(30)
svy: tab senwleaners if race==3 & likelyvoter==1, stubw(30)
svy: tab senwleaners if race==4 & likelyvoter==1, stubw(30)

svy: tab senwleaners if agecat==1 & likelyvoter==1, stubw(30)
svy: tab senwleaners if agecat==2 & likelyvoter==1, stubw(30)
svy: tab senwleaners if agecat==3 & likelyvoter==1, stubw(30)

svy: tab senwleaners if q1==1 & likelyvoter==1, stubw(30)
svy: tab senwleaners if q1==2 & likelyvoter==1, stubw(30)

svy: tab senwleaners if q2==1 & likelyvoter==1, stubw(30)
svy: tab senwleaners if q2==2 & likelyvoter==1, stubw(30)

svy: tab senwleaners if region==1 & likelyvoter==1, stubw(30)
svy: tab senwleaners if region==2 & likelyvoter==1, stubw(30)
svy: tab senwleaners if region==3 & likelyvoter==1, stubw(30)
svy: tab senwleaners if region==4 & likelyvoter==1, stubw(30)

*Senate Election Vote Preference VS Other Elections

* 2010
svy: tab senwleaners if q5==1 & likelyvoter==1, stubw(30)
svy: tab senwleaners if q5==2 & likelyvoter==1, stubw(30)
svy: tab senwleaners if q5==3 & likelyvoter==1, stubw(30)
svy: tab senwleaners if q5==4 & likelyvoter==1, stubw(30)

svy: tab senwleaners if gender==1 & q5==1 & likelyvoter==1, stubw(30)
svy: tab senwleaners if gender==2 & q5==1 & likelyvoter==1, stubw(30)

svy: tab senwleaners if pid3==1 & q5==1 & q6==1, stubw(30)
svy: tab senwleaners if pid3==2 & q5==1 & q6==1, stubw(30)
svy: tab senwleaners if pid3==3 & q5==1 & q6==1, stubw(30)

* 2012

svy: tab senwleaners if q5a==1 & likelyvoter==1, stubw(30)
svy: tab senwleaners if q5a==2 & likelyvoter==1, stubw(30)
svy: tab senwleaners if q5a==3 & likelyvoter==1, stubw(30)
svy: tab senwleaners if q5a==4 & likelyvoter==1, stubw(30)

svy: tab senwleaners if gender==1 & q5a==1 & q6==1, stubw(30)
svy: tab senwleaners if gender==2 & q5a==1 & q6==1, stubw(30)

svy: tab senwleaners if pid3==1 & q5a==1 & q6==1, stubw(30)
svy: tab senwleaners if pid3==2 & q5a==1 & q6==1, stubw(30)
svy: tab senwleaners if pid3==3 & q5a==1 & q6==1, stubw(30)

* Candidate Evals and Issue Comparisons

svy: tab q10a if likelyvoter==1, stubw(30)
svy: tab q10b if likelyvoter==1, stubw(30)
svy: tab q10c if likelyvoter==1, stubw(30)
svy: tab q10d if likelyvoter==1, stubw(30)
svy: tab q10e if likelyvoter==1, stubw(30)

